package com.me.bbs.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.me.bbs.dto.CommentDTO;
import com.me.bbs.dto.PostDTO;
import com.me.bbs.dto.SubCommentDTO;
import com.me.bbs.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.me.bbs.entity.Post;
import com.me.bbs.vo.CommentVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import javax.xml.stream.events.DTD;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author lm
 * @since 2023-01-09
 */
public interface CommentMapper extends BaseMapper<Comment> {
    Page<CommentDTO> selectByPostInPage(
            Page<CommentDTO> page,
            @Param("postId") Long postId,
            @Param("cid") Long cid
    );

    @Select("select IFNULL(MAX(`floor`),0) from comment where post = #{postId} and type = 0")
    Integer selectMaxFloor(Long postId);

    CommentDTO selectCommentDTOById(Long id);

    SubCommentDTO selectSubCommentDTOById(Long id);
    

    Page<Map<String ,Object>> selectLatest(Page<Comment> page, @Param("map") Map<String ,Object> argsMap);

    Long getUnreadCount(@Param("map") Map<String, Object> argsMap);
}
